package com.chalmers.foa.gamemodel.gameobjects.effects.impl;

import java.util.List;
import java.util.Random;

import android.graphics.Point;

import com.chalmers.foa.gamemodel.gameobjects.effects.ParticleEffect;

public class DismemberEffect extends ParticleEffect {
	final private static int PARTICLE_COUNT = 50; 
	final private static int MINSIZE = 1;
	final private static int MAXSIZE = 4;
	final private static int MINLIFE = 20;
	final private static int MAXLIFE = 40;
	final private static int MINSPEED = 1;
	final private static int MAXSPEED = 10;
	final private static int MINDIRECTION = 0;
	final private static int MAXDIRECTION = 360;
	
	Random random;
	
	List<Integer> colorList;
	
	public DismemberEffect(Point position, List<Integer> colorList) {
		super(position, PARTICLE_COUNT);
		this.colorList = colorList;
		random = new Random();
		startEffect();
	}

	@Override
	protected void startEffect() {
		int size = colorList.size();
		int amount = getParticleAmount();
		for(int i = 0; i < amount; i++) {
			int color = colorList.get((int)(random.nextInt(size)));
			particles.add(new Particle(getPosition(), color,
					MINDIRECTION +(int)(random.nextInt(MAXDIRECTION)), 
					MINSPEED +(int)(random.nextInt(MAXSPEED)),
					MINLIFE +(int)(random.nextInt(MAXLIFE)),
					MINSIZE +(int)(random.nextInt(MAXSIZE))));
		}
	}
}
